package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.BookProvider;
import com.pgybook.db.entity.domain.BookProviderEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface BookProviderMapper {
    int countByExample(BookProviderEx example);

    int deleteByExample(BookProviderEx example);

    @Delete({
            "delete from bookprovider",
            "where PROVIDERID = #{providerid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer providerid);

    @Insert({
            "insert into bookprovider (NAME, ADDRESS, ",
            "CONTACT, PHONE, ",
            "STATUS, DESCRIPTION, ",
            "CRTTIME, UPDTIME, ",
            "CRTSTAFF, UPDSTAFF)",
            "values (#{name,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, ",
            "#{contact,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, ",
            "#{status,jdbcType=INTEGER}, #{description,jdbcType=VARCHAR}, ",
            "#{crttime,jdbcType=TIMESTAMP}, #{updtime,jdbcType=TIMESTAMP}, ",
            "#{crtstaff,jdbcType=INTEGER}, #{updstaff,jdbcType=INTEGER})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "providerid", before = false, resultType = Integer.class)
    int insert(BookProvider record);

    int insertSelective(BookProvider record);

    List<BookProvider> selectByExample(BookProviderEx example);

    @Select({
            "select",
            "PROVIDERID, NAME, ADDRESS, CONTACT, PHONE, STATUS, DESCRIPTION, CRTTIME, UPDTIME, ",
            "CRTSTAFF, UPDSTAFF",
            "from bookprovider",
            "where PROVIDERID = #{providerid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    BookProvider selectByPrimaryKey(Integer providerid);

    int updateByExampleSelective(@Param("record") BookProvider record, @Param("example") BookProviderEx example);

    int updateByExample(@Param("record") BookProvider record, @Param("example") BookProviderEx example);

    int updateByPrimaryKeySelective(BookProvider record);

    @Update({
            "update bookprovider",
            "set NAME = #{name,jdbcType=VARCHAR},",
            "ADDRESS = #{address,jdbcType=VARCHAR},",
            "CONTACT = #{contact,jdbcType=VARCHAR},",
            "PHONE = #{phone,jdbcType=VARCHAR},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "DESCRIPTION = #{description,jdbcType=VARCHAR},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP},",
            "UPDTIME = #{updtime,jdbcType=TIMESTAMP},",
            "CRTSTAFF = #{crtstaff,jdbcType=INTEGER},",
            "UPDSTAFF = #{updstaff,jdbcType=INTEGER}",
            "where PROVIDERID = #{providerid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BookProvider record);
}
